<?php 
require_once BASE_PATH.'application/models/basedao'.EXT;

class moduloDAO extends baseDAO {
	
    var $table = 'modulos';
    var $id    = 'modulo_k';

    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }

    function findByPadreK($id,$data= array()){ 
	$this->_sql($data);
    	return $this->findByColumn("modulo_padre_k",array($id));
    }
    
    function getAccionesByModuloK($id)
    {
        $this->load->model("admin/acciondao");
        return $this->acciondao->findByModuloK($id);
    }


    
    function getChildren($parent_id) {
	$tree = Array();
	if (!empty($parent_id)) {
	    $tree = $this->findByPadreK($parent_id);
	    foreach ($tree as $record) {
		$ids = $this->findByPadreK($record->modulo_padre_k);
		$tree = array_merge($tree, $ids);
	    }
	}
	return $tree;
    }

}
?>